<?php
class IndexAction extends Action {
	public function index() {
		$this->display("test");
	}
	
	/**
	 * @since 2013/01/11
	 * @author Frey
	 * 登录接口
	 */
	public function doLogin() {
		
	//   返回的基础json 	
    	$resArray = array(
    		"isSuccess" =>"",//成功为Y，失败为N
    		"data"=>"",
    	);
    	$data = array();
    	
    //   检测用户名或者密码是否为空 	
    	if (empty($_POST['Upassword'])||empty($_POST ['Uid'])) {
    		$resArray["isSuccess"]="N";
    		$resArray["data"] = "has_empty";
    		echo json_encode($resArray);
    		die();
		}
				
    	$Uid = trim($_POST['Uid']);
		$Upassword = trim($_POST['Upassword']);
		
		$map['s5'] = $Uid;
		$map['password']=$Upassword;
		
		$ret = M('inspector')->where($map)->find();
		
		if ($ret != NULL){
			$resArray["isSuccess"]="Y";
    		$data["username"]=$ret["name"];
    		$resArray["data"] = $data;
    		echo json_encode($resArray);
		} else {
			$resArray["isSuccess"]="N";
    		$resArray["data"]="has_error";
    		echo json_encode($resArray);
		}
    }
}
